using System;
using System.Collections.Generic;
using System.Text;
using DAL;
using Entites;
using Utility;
namespace BUS
{
   public class TinhTrangDealBUS
    {
        public static void Insert(TinhTrangDeal ttd)
        {
            TinhTrangDealDAL ttdDAL = new TinhTrangDealDAL();
            ttdDAL.Insert(ttd);
        }
        public static void Update(TinhTrangDeal ttd)
        {
            TinhTrangDealDAL ttdDAL = new TinhTrangDealDAL();
            ttdDAL.Update(ttd);
        }
        public static void Delete(int iD)
        {
            TinhTrangDealDAL ttdDAL = new TinhTrangDealDAL();
            ttdDAL.Delete(iD);
        }
        public static tbTinhTrangDealCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            TinhTrangDealDAL ttdDAL = new TinhTrangDealDAL();
            return ttdDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbTinhTrangDealCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            TinhTrangDealDAL ttdDAL = new TinhTrangDealDAL();
            return ttdDAL.Get(cri.Criter, 0, 0, tbTinhTrangDealColumns.MaTTDeal.ToString(), OrderDirection.ASC.ToString(), out total);
        }
       public static TinhTrangDeal GetByID(int iD)
       {
           int total = 0;
           Criteria cri = new Criteria();
           cri.add(Condition.AND, tbTinhTrangDealColumns.MaTTDeal.ToString(), Condition.EQUAL, iD);
           TinhTrangDealDAL ttdDAL = new TinhTrangDealDAL();
           tbTinhTrangDealCollection tinhtrangdealcollection = ttdDAL.Get(cri.Criter,
                 0, 0, tbTinhTrangDealColumns.MaTTDeal.ToString(), OrderDirection.ASC.ToString(), out total);
           if (tinhtrangdealcollection.Count > 0)
               return tinhtrangdealcollection[0];
           return null;
       }
      
        public static tbTinhTrangDealCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            TinhTrangDealDAL ttdDAL = new TinhTrangDealDAL();
            return ttdDAL.Get(cri.Criter, 1, number,
             tbTinhTrangDealColumns.MaTTDeal.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbTinhTrangDealCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            TinhTrangDealDAL ttdDAL = new TinhTrangDealDAL();
            return ttdDAL.Get(cri.Criter, 1, number,
               tbTinhTrangDealColumns.MaTTDeal.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
    
    
}
